<!--{include admin/top.html}-->
	<div class="mainPage">
	<!--{if $do =='list'}-->
		<h1 class="title">导航列表
			<span class='sub_menu'>
				&nbsp; <a href="{:parse_uri('admin_other-nav-do-add')}">添加导航</a>
			</span>
		</h1>
		<table width="100%" align=center cellspacing=0 cellpadding=0 border=0>
		<tr >
			<td width="15%" align=center>
				<p><b>导航名称</b></p></td>
			<td width="45%" align=center><p><b>链接地址</b></p></td>
			<td width="15%" align=center><p><b>排序(大<code>-></code> 小)</b></p></td>
			<td width="10%" align=center><p><b>打开方式</b></p></td>
			<td width="10%" align=center><p><b>操作</b></p></td>
		</tr>
		<!--{foreach $nav $k $v}-->
		<tr class='ctr'>
			<td align=center>
				<p style="line-height:30px;">{$v['nav_title']}</p></td>
			<td  align=center>
				<p>{$v['nav_url']}</p>
			</td>
			<td  align=center>
				<p>&nbsp;<input type="text" value="{$v['nav_sort']}" style='width:30px;' maxlength=3 onblur="upSort({$v['nav_sort']},this.value,{$v['Id']},this)" />
				</p>
			</td>
			<td  align=center>
				<p>
					{if $v['nav_target']=='1'}
						新窗口
					{else}
						原窗口
					{/if}
				</p>
			</td>
			<td  align=center>
				<p><a href="{:parse_uri('admin_other-nav-do-del-id-%d',$v['Id'])}">删除</a></p>
			</td>
		</tr>
		<!--{/foreach}--></table>
	<script>
		// AJAX FUNC //
		function upSort(ov,val,id,obj){
			if(!isNum(val)){
				obj.value = ov;
				return false;
			}
			ov = parseInt(ov);
			val = parseInt(val);
			if(ov == val){
				return false; 
			}
			var url = '{:parse_uri("admin_other-ajax-do-navsort-id-#id#-val-#val#")}';
			url = url.replace('#id#',id).replace('#val#',val);
			$.get(url, function(data){
				if(parseInt(data)==250){
					location.reload();
				}
			});
		}
		function isNum(s){
			var patrn=/^[0-9]{1,3}$/;
			if (!patrn.exec(s)){
				return false;
			}
			return true;
		}
	</script>
	<!--{elseif $do == 'add'}-->
	<script>
		function usePage(obj){
			obj = $(obj);
			if(obj.val()=='0'){
				$("#nav_title").val('');
				$("#nav_url").val('');
				$("#nav_title").val('');
			}else{
				$("#nav_title").val(obj.text());
				if(obj.attr('type')=='1'){
					$("#nav_url").val(obj.attr('link_url'));
				}else{
					$("#nav_url").val('{:parse_uri("page-v-id-|false")}'+obj.val()+'{$GLOBALS["ora_cfg"]['url_suffix']}');
				}
			}
		}
		function show(){
			if($("#sl_panel").css('display')=='none'){
				$("#sl_panel").css('display','block');
			}else{
				$("#sl_panel").css('display','none');
			}
		}
	</script>
		<h1 class="title">添加导航
			<span class='sub_menu'>
				&nbsp; <a href="{:parse_uri('admin_other-nav-do-list')}">返回列表</a>
			</span>
		</h1>
		
		<form action="{:parse_uri('admin_other-nav-do-save')}" method="post">
		<p>导航名称: <input name="nav_title" id="nav_title" class="ipt"/></p>
		<p>链接地址: <input name="nav_url" id="nav_url" class="ipt"/></p>
		<p>打开方式: 新窗口 <input name="nav_target" type="radio" value="1" checked /> 
					 原窗口 <input name="nav_target" type="radio"  value="0" />
		</p>
		<p style="margin-top:10px;">使用自定义页面: <input type="checkbox" onclick="show()" /> </p>
		<p id="sl_panel" style="display:none">
		页面列表:
			<select onchange="usePage(this.options[this.options.selectedIndex])">
				<option value=0>请选择页面</option>
				{foreach $nav $k $v}
				<option value="{$v['Id']}" link_url = "{$v['url']}" type="{$v['ptype']}" >{$v['name']}</option>
				{/foreach}
			</select>
		</p>
		<p style='margin-top:10px;'><input type="submit" value='提交'class="submit"/></p>
		</form>
	<!--{/if}-->
		<p>
			&nbsp;
		</p>
	</div>
</body>
</html>